home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5536 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: int main() vs int main(void)
  5. Date: 08 Feb 1996 15:43:18 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb8084318@qcd.lanl.gov>
  8. References: <1996Feb7.201848.18734@atlas.tntech.edu>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: jad7084@tntech.edu's message of 7 Feb 96 20:18:48 -0500
  13.  
  14. In article <1996Feb7.201848.18734@atlas.tntech.edu> jad7084@tntech.edu
  15. (Jim Davis) writes: 
  16. <snip>
  17.    Okay, void main() is naughty, but there's something else I've been
  18.    wondering about, and I can't find it in the FAQ.
  19.  
  20.    Is there a difference between
  21.  
  22.      int main()
  23.      int main(void)
  24.  
  25.    ?  () is equivalent to (void), right?  Does it matter?  Am I worried about
  26.    nothing?
  27.  
  28. int main() in the definition (the only normal use :-) is equivalent to
  29. int main(void). In a declaration (if you want to declare a function
  30. before defining or otherwise using it), int main() means that main has
  31. a fixed number of parameters which is not being declared here: that is
  32. also correct.
  33.  
  34. Only things to check out for the type of main are:
  35.  
  36. 1) it returns an int.
  37. 2) it has either no parameters
  38.    or two parameters
  39. 3) it is not a vararg function (i.e. you cannot sometime call it with
  40.    0 and sometime with 2 parameters: neither can you declare it to
  41.    take a varying number of parameters.)
  42. 4) if it has two parameters, the first is an int
  43.    and the second is char *argv[], which _in parameter context_ is same
  44.    as char **argv.
  45.  
  46. Cheers
  47. Tanmoy
  48. --
  49. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  50. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  51. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  52. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  53. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  54. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  55.